@import '/variable.less';

/* 流萤主题 - 星空闪烁动画 */
@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* 流萤主题背景装饰 */
.firefly-theme-bg {
  .star {
    box-shadow: 0 0 6rpx rgba(139, 92, 246, 0.5);
  }
}

.community-container {
  min-height: 100vh;
  /* 流萤主题：淡淡的紫蓝夜空渐变，营造个人书房氛围 */
  background: linear-gradient(135deg, 
    #f8fafc 0%,           /* 淡蓝白色 */
    #f1f5fb 25%,          /* 极淡蓝色 */
    #e8f0fe 50%,          /* 淡蓝色 */
    #f3f0ff 75%,          /* 淡紫色 */
    #faf7ff 100%          /* 淡紫白色 */
  );
  padding-bottom: 100px;
  position: relative;
}

/* 顶部区域 */
.top-section {
  position: sticky;
  top: 0;
  z-index: 100;
  /* 保持与主背景一致的渐变 */
  background: linear-gradient(135deg, 
    #f8fafc 0%, 
    #f1f5fb 25%, 
    #e8f0fe 50%, 
    #f3f0ff 75%, 
    #faf7ff 100%
  );
  border-bottom: 1px solid rgba(99, 102, 241, 0.08);
  backdrop-filter: blur(10px);
}

/* 搜索框 */
.search-container {
  padding: 16px 20px 12px;

  .search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    /* 半透明搜索框，融入夜空氛围 */
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    padding: 12px 16px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(99, 102, 241, 0.1);

    .search-input {
      flex: 1;
      font-size: 14px;
      color: #333333;
      background: transparent;
      border: none;
      outline: none;

      &::placeholder {
        color: #888888;
      }
    }
  }
}

/* 分类标签栏 */
.category-tabs {
  padding: 0 20px 16px;

  .tabs-scroll {
    white-space: nowrap;
  }

  .tabs-container {
    display: inline-flex;
    gap: 12px;
    padding-right: 20px;
  }

  .tab-item {
    padding: 8px 16px;
    /* 融入夜空主题的标签样式 */
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    font-size: 14px;
    color: #555555;
    white-space: nowrap;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(99, 102, 241, 0.1);

    &:active {
      transform: scale(0.95);
    }

    &.active {
      /* 活跃状态使用紫蓝渐变 */
      background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
      color: #FFFFFF;
      box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    }
  }
}

/* 内容流 */
.content-stream {
  padding: 0;
  width: 100%;
}

/* 内容列表容器 */
.posts-list {
  width: 100%;
  max-width: 750rpx;
  margin: 0 auto;
  padding: 0 24rpx;
  box-sizing: border-box;
}

/* 云汉卡片 - 层次化优化 */
.yunhan-card {
  /* 纯白背景，增强呼吸感 */
  background: #ffffff;
  border-radius: 16rpx;
  margin-bottom: 24rpx;
  padding: 24rpx;
  /* 柔和阴影，避免过重 */
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: none; /* 移除边框，使用阴影分隔 */
  
  /* 鼠标悬停效果 */
  &:hover {
    box-shadow: 0 6rpx 24rpx rgba(0, 0, 0, 0.12);
    transform: translateY(-2rpx);
  }

  /* 用户区域样式 */
  .card-user-section {
    .user-avatar {
      border: 2rpx solid #f1f5f9;
    }

    .user-nickname {
      font-weight: 600;
      color: #1e293b;
    }

    .post-time {
      color: #94a3b8;
      font-size: 24rpx;
    }
  }

  /* 内容区域样式 */
  .card-content-section {
    .book-info-compact {
      .book-cover-small {
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
      }

      .book-title {
        font-weight: 700;
        color: #1e293b;
        line-height: 1.3;
      }

      .book-author {
        color: #64748b;
        font-weight: 500;
      }
    }

    .quote-content-preview {
      .quote-text {
        color: #1e293b;
        font-weight: 400;
        line-height: 1.6;
        cursor: pointer;
        transition: all 0.3s ease;
        background: transparent !important; // 确保背景透明

        &.expanded {
          display: block !important;
          -webkit-line-clamp: unset !important;
          overflow: visible !important;
        }

        &:active {
          opacity: 0.7;
          background: transparent !important; // 点击时也保持背景透明
        }

        &:hover {
          background: transparent !important; // 悬停时也保持背景透明
        }
      }
    }

    .thoughts-section {
      background: #f8fafc;
      border-left: 3rpx solid #3b82f6;

      .thoughts-text {
        color: #64748b;
        font-style: italic;
        cursor: pointer;
        transition: all 0.3s ease;
        background: transparent !important; // 确保背景透明

        &.expanded {
          display: block !important;
          -webkit-line-clamp: unset !important;
          overflow: visible !important;
        }

        &:active {
          opacity: 0.7;
          background: transparent !important; // 点击时也保持背景透明
        }

        &:hover {
          background: transparent !important; // 悬停时也保持背景透明
        }
      }
    }
  }

  /* 操作区域样式 */
  .card-actions-section {
    /* 使用更轻的分隔线 */
    border-top: 1rpx solid #f1f5f9;
    
    .action-btn {
      transition: all 0.3s ease;
      cursor: pointer;

      &:hover {
        background: rgba(59, 130, 246, 0.05) !important;
        transform: scale(1.05);
      }

      &:active {
        transform: scale(0.95);
      }
    }
  }
}

/* 用户信息区 */
.user-info-section {
  display: flex;
  align-items: center;
  margin-bottom: 12px;

  .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;

    image {
      width: 100%;
      height: 100%;
    }
  }

  .user-details {
    flex: 1;

    .user-name {
      font-size: 16px;
      font-weight: bold;
      color: #333333;
      margin-bottom: 4px;
    }

    .user-badges {
      display: flex;
      align-items: center;
      gap: 8px;

      .title-badge {
        padding: 2px 8px;
        /* 标题徽章使用紫蓝渐变 */
        background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
        color: #FFFFFF;
        border-radius: 10px;
        font-size: 12px;
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
      }

      .badge-icon {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        overflow: hidden;

        image {
          width: 100%;
          height: 100%;
        }
      }
    }
  }

  .post-time {
    font-size: 12px;
    color: #888888;
  }
}

/* 书摘/感受区 */
.content-section {
  margin-bottom: 16px;

  .text-content {
    margin-bottom: 12px;

      .content-text {
        font-size: 14px;
        line-height: 1.6;
        color: #333333;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;

        &.expanded {
          -webkit-line-clamp: unset;
          line-clamp: unset;
        }
      }

    .expand-btn {
      font-size: 14px;
      /* 展开按钮使用紫色调 */
      color: #8b5cf6;
      margin-top: 8px;
      display: inline-block;
      font-weight: 500;
    }
  }

  .image-section {
    margin-bottom: 12px;

    .image-grid {
      &.single {
        image {
          width: 100%;
          max-height: 300px;
          border-radius: 8px;
        }
      }

      &.multiple {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;

        image {
          width: 100%;
          height: 100px;
          border-radius: 4px;
        }
      }
    }
  }

  .book-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    /* 书籍信息区域使用淡紫色背景 */
    background: rgba(248, 250, 252, 0.8);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(139, 92, 246, 0.1);

    .book-cover {
      width: 40px;
      height: 50px;
      border-radius: 6px;
    }

    .book-details {
      flex: 1;

      .book-title {
        font-size: 14px;
        font-weight: bold;
        color: #333333;
        margin-bottom: 4px;
      }

      .book-author {
        font-size: 12px;
        color: #888888;
      }
    }
  }
}

/* 互动区 */
.interaction-section {
  margin-bottom: 12px;

  .like-bubbles {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;

    .like-avatar {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      overflow: hidden;
      border: 2px solid #FFFFFF;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

      image {
        width: 100%;
        height: 100%;
      }
    }

    .like-count {
      font-size: 12px;
      color: #888888;
      margin-left: 4px;
    }
  }

  .action-buttons {
    display: flex;
    justify-content: space-around;
    border-top: 1px solid #F0F0F0;
    padding-top: 12px;

    .action-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 12px;
      border-radius: 6px;
      transition: all 0.3s ease;

      &:active {
        background: rgba(0, 0, 0, 0.05);
        transform: scale(0.95);
      }

      .action-count {
        font-size: 14px;
        color: #888888;
      }
    }
  }
}

/* 评论区 */
.comments-section {
  border-top: 1px solid #F0F0F0;
  padding-top: 12px;

  .comment-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;

    .comment-user {
      .comment-nickname {
        font-size: 14px;
        font-weight: 500;
        color: #333333;
      }
    }

    .comment-content {
      font-size: 14px;
      color: #666666;
      line-height: 1.4;
    }
  }

  .view-all-comments {
    font-size: 14px;
    /* 查看全部评论按钮使用紫色调 */
    color: #8b5cf6;
    margin-top: 8px;
    font-weight: 500;
  }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;

  .empty-icon-placeholder {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 空状态图标使用半透明紫色背景 */
    background: rgba(139, 92, 246, 0.1);
    border-radius: 50%;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(139, 92, 246, 0.2);
  }

  .empty-text {
    font-size: 16px;
    color: #6b7280;
  }
}

/* 加载状态 */
.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

/* 没有更多 */
.no-more {
  text-align: center;
  padding: 20px 0;
  font-size: 14px;
  color: #888888;
}

/* 评论输入框 - 微信样式 */
.comment-input-container {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;

  .comment-input-mask {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    /* 遮罩使用深紫色调 */
    background: rgba(30, 64, 175, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .comment-input-box {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    /* 输入框背景使用半透明白色，保持夜空氛围 */
    background: rgba(255, 255, 255, 0.95);
    border-top: 1rpx solid rgba(99, 102, 241, 0.2);
    padding: 20rpx 32rpx;
    padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 24rpx;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    backdrop-filter: blur(20px);
  }

  &.show {
    .comment-input-mask {
      opacity: 1;
    }
    
    .comment-input-box {
      transform: translateY(0);
    }
  }
}
